package com.gxa.finance.controller;

import com.gxa.common.commons.R;
import com.gxa.finance.pojo.Pricing;
import com.gxa.finance.service.PricingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Component
@RestController
@RequestMapping("/pricing")
public class PricingController {
    @Autowired
    private PricingService pricingService;

    /**
     * 添加单条定价服务
     * @param pricing
     * @return
     */
    @GetMapping("/addPricing")
    public R addPricing(@RequestBody Pricing pricing){
        return pricingService.addPricing(pricing);

    }

    /**
     * 添加多条数据(没用)
     * @param pricings
     * @return
     */
//    @PostMapping("/addPricingList")
//    public R addPricingList(@RequestBody List<Pricing> pricings){
//        return pricingService.addPricingList(pricings);
//    }


    /**
     * 根据服务类型查询定价信息
     * @param pType
     * @return
     */
    @GetMapping("/findPricing")
    public R findPricing(String pType){
        return pricingService.findPricing(pType);
    }

    /**
     * 根据id删除定价服务
     * @param id
     * @return
     */
    @PostMapping("/delByIdPricing")
    public R delByIdPricing(Integer id){
        return pricingService.delByIdPricing(id);
    }

    /**
     * 根据id修改定价服务
     * @param pricing
     * @return
     */
    @PostMapping("/updateByIdPricing")
    public R updateByIdPricing(@RequestBody Pricing pricing){
        return pricingService.updateByIdPricing(pricing);
    }


}
